// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import i18n from './lang'
import SvgIcon from '@/components/SvgIcon'
import ImgCard from '@/components/ImgCard'
import Occupied from '@/components/Occupied'
import requestApi from '@/utils/requestUtil/api'
import { isExistShopAuthoritys } from '@/utils/util'

import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/css/index.less'
import VueClipboard from 'vue-clipboard2'

import { transformImgUrl, formatDateTime } from '@/filters'

Vue.use(Element, { zIndex: 3000 })
VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)
Vue.component('svg-icon', SvgIcon)
Vue.component('img-card', ImgCard)
Vue.component('occupied-card', Occupied)
Vue.prototype.$http = requestApi
Vue.prototype.$isExistShopAuthoritys = isExistShopAuthoritys
// 全局pageSize管理
Vue.prototype.$pageSize = store.getters.pageSize
Vue.prototype.$pageSizeList = store.getters.pageSizeList
Vue.prototype.$pageSizeChange = (pageSize) => {
  return store.dispatch('pageSizeChange', pageSize).then(() => {
    Vue.prototype.$pageSize = store.getters.pageSize
  })
}
Vue.prototype.$GetAdminNoticeNums = (arr = []) => {
  let sum = 0
  for (let i = 0; i < arr.length; i++) {
    if (store.getters.adminNoticeSet[arr[i]]) {
      sum += store.getters.adminNoticeSet[arr[i]]
    }
  }
  return sum
}
Vue.prototype.routerToTag = (url) => {
  router.push(url)
}
Vue.config.productionTip = false
/* 全局过滤器 */
Vue.filter('xxTransformImgUrl', transformImgUrl)
Vue.filter('xxFormatDateTime', formatDateTime)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: { App },
  template: '<App/>'
})
